#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    int year = 0, month = 0, day = 0, vardayiy = 0;
    scanf("%d %d %d", &year, &month, &day);
    int monthday[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
        monthday[2] = 29;
    for (int i = 0; i < month; i++)
    {
        vardayiy += monthday[i];
    }
    printf("%d", vardayiy + day);
    return 0;
}